<?php 
function trunc($phrase, $max_words) {
   $phrase_array = explode(' ',$phrase);
   if(count($phrase_array) > $max_words && $max_words > 0)
      $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...';
   return $phrase;
}
?>
<div class="content_pink text-center">
    <div class="cover">
        <div class="cover_images">
            <img src="<?php echo $domain; ?>/images/cover-sp.png"/>
        </div>
        <div class="cover_flower">
            <img src="<?php echo $domain; ?>/images/cover_flower.png"/>
        </div>
    </div><!--cover-->
    <div class="box_contact">
        <div class="content_contact">
            <div class="icon_flower1">
                <img src="<?php echo $domain; ?>/images/icon_flower1.png"/>
            </div>
            <div class="icon_flower2">
                <img src="<?php echo $domain; ?>/images/icon_flower2.png"/>
            </div>
            <div class="contact">
                <h1>Liên hệ</h1>
                <span>+84(4)6273-1346</span>
                <span>080-4135-6092</span>
            </div>
        </div>
    </div><!--lien he-->
</div><!--content-->
<div class="sp-list-product text-center">
    <div class="sp-border">
        <div class="list-danhmuc">
            <div class="icon_flower4">
                <img src="<?php echo $domain; ?>/images/icon_flower_sp_hot.png"/>
            </div>
            <div class="content-danhmuc">
                <h1>DANH MỤC SẢN PHẨM</h1>
                <ul>
                    <?php foreach($categories as $cat) { ?>
                    <li><?php
                    echo $this->Html->link(
                            trunc($cat['ProductCategory']['name'],5), array('controller' => 'Product', 'action' => 'category', $cat['ProductCategory']['alias'])
                    );
                    ?></li>
                    <?php } ?>
                </ul>
            </div>
            <div class="content-danhmuc hot-news">
                <h1>BÀI NỔI BẬT</h1>
                <ul>
                    <?php foreach($other_news as $n) { ?> <li> <?php echo $this->Html->link(
                            trunc($n['News']['name'],5), array('controller' => 'News', 'action' => 'detail', $n['News']['alias']), array('escape' => false, 'title' => $n['News']['name'])
                    );
                    ?></li> <?php } ?>
                </ul>
            </div>
        </div>
        <div class="product-main">
            <div class="border-product-main">
                <div class="box-product">
   
                        <div class="main-content-sp">
                            <?php if(!empty($list_product)){
                                $count_product = count($list_product);
                                foreach($list_product as $key => $value){?>
                                <div class="item-product">
                                    <div class="img-item">
                                        <?php echo $this->Html->link(
                                            $this->Html->image(DOMAIN.'timthumb.php?w=210&h=187&zc=1&src='.$value['Product']['images'], array('alt' => $value['Product']['name'],'style' => 'width: 114px; height: 122px;')),
                                            array('controller' => 'Product', 'action' => 'detail', $value['Product']['alias']),
                                            array('escape' => false, 'title' => $value['Product']['name'])
                                        ); ?>
                                    </div>
                                    <div class="des-item">
                                        <p>
                                            <?php echo $this->Html->link(
                                            $value['Product']['name'],
                                            array('controller' => 'Product', 'action' => 'detail', $value['Product']['alias']),
                                            array('title' => $value['Product']['name'])
                                        ); ?>
                                        </p>
                                        <label><?php echo '€'.$value['Product']['price']; ?>đ</label>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    
                            <?php if($key % 3 == 2){?>
                                <div class="line"></div>
                            <?php } ?>
                        <?php  }  ?>
                        
                </div>
                
            </div>
            
            <div class="page-product">
                <ul class="list-inline">
                <?php
                    if ($this->Paginator->counter('{:pages}') > 1) {
                        echo $this->Paginator->numbers(array( 'separator' => '', 'tag' => 'li', 'currentLink' => true, 'currentClass' => 'active', 'currentTag' => 'a'));
                    }
                    ?>
                </ul>
            </div>
            
        </div>
    </div>
</div>